import { getBookMsg } from '@/api/books.js'
export default {
  namespaced: true,
  state: ()=>({
    //   图书数据
    packageData: [],
    recommend: [],
    head_config: [],
    stage_config: [],
    book_config: [],
    qa_config: [],
    buy_config: []
  }),
  mutations: {
    setBookMsg(state, data) {
      let { package: packageData, buy_config, recommend, head_config, stage_config, book_config, qa_config } = data
      state.packageData = packageData
      state.recommend = recommend
      state.head_config = head_config
      state.stage_config = stage_config
      state.book_config = book_config
      state.qa_config = qa_config
      state.buy_config = buy_config
    }
  },
  actions: {
    async getBookMsg({ commit }, params) {
      let { profession_id } = params
      if (!profession_id) return
      try {
        let { errcode, errmsg, data } = await getBookMsg(params)
        if (+errcode === 0) {
          commit('setBookMsg', data)
        }
      } catch (err) {}
    }
  },
  getters: {}
}
